package com.yjzx.util.common.util.batch.merging;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Function;

/**
 * @author yjzx
 * @date 2024/8/27
 * @description OverviewMergingBuilder
 */
public final class OverviewMergingBuilder<T, U extends Comparable<U>,R> {
    /**
     * 需要判断大小的起始获取
     */
    private Function<T, U> uStartGet;
    /**
     * 需要判断大小的起始修改
     */
    private BiConsumer<T, U> uStartSet;
    /**
     * 需要判断大小的结束获取
     */
    private Function<T, U> uEndGet;
    /**
     * 需要判断大小的结束修改
     */
    private BiConsumer<T, U> uEndSet;
    private final DataMerging<T, U,R> data;

    OverviewMergingBuilder(DataMerging<T, U,R> data) {
        this.data = data;
    }
    /**
     * 需要判断大小的起始获取
     */
    public OverviewMergingBuilder<T, U,R> uStartGet(Function<T, U> uStartGet) {
        this.uStartGet = uStartGet;
        return this;
    }
    /**
     * 需要判断大小的起始修改
     */
    public OverviewMergingBuilder<T, U,R> uStartSet(BiConsumer<T, U> uStartSet) {
        this.uStartSet = uStartSet;
        return this;
    }
    /**
     * 需要判断大小的结束获取
     */
    public OverviewMergingBuilder<T, U,R> uEndGet(Function<T, U> uEndGet) {
        this.uEndGet = uEndGet;
        return this;
    }
    /**
     * 需要判断大小的结束修改
     */
    public OverviewMergingBuilder<T, U,R> uEndSet(BiConsumer<T, U> uEndSet) {
        this.uEndSet = uEndSet;
        return this;
    }

    public OverviewMerging<T, U,R> build() {
        return new OverviewMerging<>(data, uStartGet, uStartSet, uEndGet, uEndSet);
    }
    public List<R> toDataMerging(){
        return this.build().toDataMerging();
    }
}
